var num = 10;
var obj = { num: 20 };

obj.fn = (function (num) {

    this.num = num * 3; // 分情况 20*3=60 //自执行函数指向window

    console.log('this=>', this)
    console.log('this=>', this.num)
    num++; //21

    return function (n) {
        this.num += n;  //谁调用加谁 15  //70
        num++; //22 
        console.log(num); //22 23
    };
})(obj.num); //20

console.log(num, obj.num); //15//70

var fn = obj.fn;

fn(5); //window调用

obj.fn(10);

// console.log(num, obj.num); //65//30
//直接用object.assign(obj) 是浅拷贝
//直接用object.assign({},obj) 第一层是深拷贝，第二层以后是浅拷贝
// var obj = { a: 1, b: 2, c: { name: '李兵' } }
// var obj1 = Object.assign({}, obj)
// obj1.a = 3
// obj1.c.name = 'libing'
// console.log(obj.a)
// console.log(obj.c)

let obj1 = { name: 'Kobe', address: { x: 100, y: 100 } }
let obj2 = { ...obj1 }
obj1.address.x = 200;
obj1.name = 'wade'
console.log('obj2', obj2) // obj2 { name: 'Kobe', address: { x: 200, y: 100 } }
